From 5fea642f16cefb08d32d69013b2bc845670f2486 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Mon, 5 May 2014 17:59:54 +0200 Subject: [PATCH] Content: Deprecate and stop using getHighlightHtml() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit That function was clearly a bad idea, everyone should just use getHtml() instead. It was supposed to allow extensions to extend the content formatting process, but actually doesn't. A better hook-based solution follows in separate commit I979e2438. Split off from original I979e2438 and rebased with minor changes (updated documentation comments, etc.). Co-Authored-By: daniel Co-Authored-By: Bartosz Dziewoński Change-Id: I76412f9d28bb145fb5975f59e538f6560e50472f --- includes/content/CssContent.php | 2 +- includes/content/JavaScriptContent.php | 2 +- includes/content/TextContent.php | 27 ++++++++++++++++++-------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/includes/content/CssContent.php b/includes/content/CssContent.php index 5fc2c9f158..2673084ebe 100644 --- a/includes/content/CssContent.php +++ b/includes/content/CssContent.php @@ -67,7 +67,7 @@ class CssContent extends TextContent { protected function getHtml() { $html = ""; $html .= "
\n";
-		$html .= $this->getHighlightHtml();
+		$html .= htmlspecialchars( $this->getNativeData() );
 		$html .= "\n
\n"; return $html; diff --git a/includes/content/JavaScriptContent.php b/includes/content/JavaScriptContent.php index 11a470e1e4..442b705282 100644 --- a/includes/content/JavaScriptContent.php +++ b/includes/content/JavaScriptContent.php @@ -66,7 +66,7 @@ class JavaScriptContent extends TextContent { protected function getHtml() { $html = ""; $html .= "
\n";
-		$html .= $this->getHighlightHtml();
+		$html .= htmlspecialchars( $this->getNativeData() );
 		$html .= "\n
\n"; return $html; diff --git a/includes/content/TextContent.php b/includes/content/TextContent.php index 0c6b06f177..4c95d3c977 100644 --- a/includes/content/TextContent.php +++ b/includes/content/TextContent.php @@ -242,10 +242,12 @@ class TextContent extends AbstractContent { * Generates an HTML version of the content, for display. Used by * getParserOutput() to construct a ParserOutput object. * - * This default implementation just calls getHighlightHtml(). Content - * models that have another mapping to HTML (as is the case for markup - * languages like wikitext) should override this method to generate the - * appropriate HTML. + * Subclasses may override this to provide a custom HTML rendering. + * If further information is to be derived from the content (such as + * categories), the getParserOutput() method can be overridden instead. + * + * For backwards-compatibility, this default implementation just calls + * getHighlightHtml(). * * @return string An HTML representation of the content */ @@ -254,13 +256,22 @@ class TextContent extends AbstractContent { } /** - * Generates a syntax-highlighted version of the content, as HTML. - * Used by the default implementation of getHtml(). + * Generates an HTML version of the content, for display. + * + * This default implementation returns an HTML-escaped version + * of the raw text content. + * + * @note: The functionality of this method should really be implemented + * in getHtml(), and subclasses should override getHtml() if needed. + * getHighlightHtml() is kept around for backward compatibility with + * extensions that already override it. * - * @return string A HTML representation of the content's markup + * @deprecated since 1.24. Use getHtml() instead. In particular, subclasses overriding + * getHighlightHtml() should override getHtml() instead. + * + * @return string An HTML representation of the content */ protected function getHighlightHtml() { - # TODO: make Highlighter interface, use highlighter here, if available return htmlspecialchars( $this->getNativeData() ); } -- 2.20.1